# binreposd.py

import sys
import optparse
import barco.error
import barco.binreposd

## main() ##
def main():
    server = barco.binreposd.Server()
    def set_repository(option, opt, value, parser): server.set_repository(value)
    usage = list()
    usage.append('usage: binreposd [options]')
    parser = optparse.OptionParser(usage='\n'.join(usage), version='0.1')
    parser.add_option('-r', '--repository', 
                      type='string',
                      action='callback', callback=set_repository,
                      help='directory containing the binary repository')
    parser.parse_args()
    try: server.run()
    except barco.error.Error as e: parser.error(str(e))
    return 0

# execute main() if we are being run as standalone script.
if __name__ == '__main__': sys.exit(main())
